home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / CostManager / CostManager.jar / Type.class (.txt) < prev   
Encoding:
Java Class File  |  2001-09-04  |  2.7 KB  |  86 lines

  1. import java.io.ByteArrayInputStream;
  2. import java.io.ByteArrayOutputStream;
  3. import java.io.DataInputStream;
  4. import java.io.DataOutputStream;
  5. import java.io.IOException;
  6.  
  7. class Type {
  8.    // $FF: renamed from: id int
  9.    private int field_0;
  10.    private String name;
  11.  
  12.    Type(int id, String name) {
  13.       this.field_0 = id;
  14.       this.name = name;
  15.    }
  16.  
  17.    Type(String name) {
  18.       this(0, name);
  19.    }
  20.  
  21.    Type(byte[] vec) {
  22.       this.initialize(vec);
  23.    }
  24.  
  25.    String getName() {
  26.       return this.name;
  27.    }
  28.  
  29.    int getId() {
  30.       return this.field_0;
  31.    }
  32.  
  33.    void setId(int idVal) {
  34.       this.field_0 = idVal;
  35.    }
  36.  
  37.    void initialize(byte[] vec) {
  38.       ByteArrayInputStream bais = null;
  39.       DataInputStream dis = null;
  40.  
  41.       try {
  42.          bais = new ByteArrayInputStream(vec);
  43.          dis = new DataInputStream(bais);
  44.          this.field_0 = dis.readInt();
  45.          this.name = dis.readUTF();
  46.       } catch (IOException var14) {
  47.          ((Throwable)var14).printStackTrace();
  48.       } finally {
  49.          try {
  50.             bais.close();
  51.             dis.close();
  52.          } catch (IOException var13) {
  53.             ((Throwable)var13).printStackTrace();
  54.          }
  55.  
  56.       }
  57.  
  58.    }
  59.  
  60.    byte[] toBytes() {
  61.       byte[] data = null;
  62.       ByteArrayOutputStream baos = null;
  63.       DataOutputStream dos = null;
  64.  
  65.       try {
  66.          baos = new ByteArrayOutputStream();
  67.          dos = new DataOutputStream(baos);
  68.          dos.writeInt(this.field_0);
  69.          dos.writeUTF(this.name);
  70.          data = baos.toByteArray();
  71.       } catch (Exception var14) {
  72.          ((Throwable)var14).printStackTrace();
  73.       } finally {
  74.          try {
  75.             baos.close();
  76.             dos.close();
  77.          } catch (IOException var13) {
  78.             ((Throwable)var13).printStackTrace();
  79.          }
  80.  
  81.       }
  82.  
  83.       return data;
  84.    }
  85. }
  86.